<?php
$categories_obj = new Category();

function show_categories(){
	global $categories_obj, $KToolBar;
	$categories = $categories_obj->find("all");
	include_once 'views/categories.html.php';
}

function new_category(){
	global $categories_obj, $KToolBar;
	
	include_once 'views/categories_new.html.php';
}

function save_new_category(){
	global $categories_obj, $notice;
	$notice['error'] = 1;
	if(empty($_POST['category'])){
		$notice['msg'] = "You cannot create a category without specifying a name";
	}
	else $notice = $categories_obj->insert_or_update($_POST['category'],"");
	if($notice['error'] == 0) $notice['msg'] = "A new category has been created";
}

function delete_selected_categories(){
	global $categories_obj, $notice;
	$notice = delete_selected_items($_POST['categories'], $categories_obj);
	if($notice['error'] == 0) $notice['msg'] = "The selected items have been deleted";
	if($notice['error'] == 1) $notice['msg'] = "The selected items cannot be deleted";
}
?>